package com.codefish.service.impl;

import com.codefish.entity.BaseFamily;
import com.codefish.mapper.BaseFamilyDao;
import com.codefish.service.BaseFamilyService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.time.LocalDateTime;
import java.util.UUID;


@Service("baseFamilyService")
public class BaseFamilyServiceImpl extends ServiceImpl<BaseFamilyDao, BaseFamily> implements BaseFamilyService {

    /**
     * 添加单个
     *
     * @param family
     * @return
     */
    @Override
    public boolean saveOne(BaseFamily family) {
        String uuid= UUID.randomUUID().toString().replace("-", "");
        family.setUuid(uuid);
        family.setCreateTime(LocalDateTime.now());
        int saveCount = baseMapper.insert(family);

        if (saveCount == 1) {
            return true;
        }

        return false;
    }

    /**
     * 修改单个
     * @param family
     * @return
     */
    @Override
    public boolean updateOne(BaseFamily family) {

        boolean flag = this.updateById(family);
        return flag;
    }
}